﻿using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace ZilLion.Service.TaskPlatform.Domain.Entity
{
    public class NodeMonitorDto : NodeRunMonitorInfoEntity
    {
        /// <summary>
        ///     执行任务数
        /// </summary>
        [JsonProperty("nodeExcuteingTaskCount")]
        public int NodeExcuteingTaskCount
        {
            get { return Tasks?.Where(x => x.Taskstatus == 0).ToList().Count ?? 0; }
        }

        /// <summary>
        ///     已停止任务数
        /// </summary>
        [JsonProperty("nodeUnExcuteingTaskCount")]
        public int NodeUnExcuteingTaskCount
        {
            get { return Tasks?.Where(x => x.Taskstatus == 1).ToList().Count ?? 0; }
        }

        public IList<TaskStateEntity> Tasks { get; set; } = new List<TaskStateEntity>();
    }
}